//
//  YNSLoginVC.m
//  HNBaseProject
//
//  Created by TR on 2024/6/19.
//

#import "YNSLoginVC.h"
#import "YNSHomeController.h"
@interface YNSLoginVC ()

@property(nonatomic,strong)UILabel          *tLab1;
@property(nonatomic,strong)UILabel          *tLab2;
@property(nonatomic,strong)UILabel          *tLab3;
@property(nonatomic,strong)UIButton         *kfBtn;

@property(nonatomic,strong)UIView           *bgView;
@property(nonatomic,strong)UILabel          *tLab4;
@property(nonatomic,strong)UIImageView      *phoneImageV;
@property(nonatomic,strong)UITextField      *phoneTF;
@property(nonatomic,strong)UILabel          *phoneLineLab;
@property(nonatomic,strong)UIImageView      *pwdImageV;
@property(nonatomic,strong)UITextField      *pwdTF;
@property(nonatomic,strong)UILabel          *pwdLineLab;
@property(nonatomic,strong)ExpandButton         *changeBtn;

@property(nonatomic,strong)UIButton         *loginBtn;
@property(nonatomic,strong)ExpandButton         *choseBtn;//选择
@property(nonatomic,strong)YYLabel          *choseLab;//阅读

@end

@implementation YNSLoginVC

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.view.backgroundColor = [UIColor colorWithHexString:@"#106CFA"];
    
    [self setUI];
}
- (void)setUI{
    self.tLab1 = [[UILabel alloc]init];
    self.tLab1.text = @"欢迎登录";
    self.tLab1.textColor = [UIColor colorWithHexString:@"#FFFFFF"];
    self.tLab1.font =PFRFontSemibold(17);
    [self.view addSubview:self.tLab1];
    
    self.tLab2 = [[UILabel alloc]init];
    self.tLab2.text = @"云律士法务";
    self.tLab2.textColor = [UIColor colorWithHexString:@"#FFFFFF"];
    self.tLab2.font =PFRFontSemibold(28);
    [self.view addSubview:self.tLab2];
    
    self.tLab3 = [[UILabel alloc]init];
    self.tLab3.text = @"最适合企业的法律服务";
    self.tLab3.textColor = [UIColor colorWithHexString:@"#FFFFFF"];
    self.tLab3.font =[UIFont systemFontOfSize:16];
    [self.view addSubview:self.tLab3];
    
    self.kfBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    [self.kfBtn setTitle:@"联系管理员" forState:UIControlStateNormal];
    self.kfBtn.titleLabel.font = [UIFont systemFontOfSize:12];
    [self.kfBtn setImage:[UIImage imageNamed:@"gly"] forState:UIControlStateNormal];
    [self.kfBtn setTitleColor:[UIColor colorWithHexString:@"#FFFFFF"] forState:UIControlStateNormal];
    self.kfBtn.backgroundColor = RGBA_COLOR(0, 0, 0, 0.26);
    [self.kfBtn addTarget:self action:@selector(kfClick) forControlEvents:UIControlEventTouchUpInside];
    self.kfBtn.layer.masksToBounds = YES;
    self.kfBtn.layer.cornerRadius = 16.5;
    [self.view addSubview:self.kfBtn];
    
    [self.tLab1 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.offset(kNavBarHeight+39);
        make.left.offset(20);
    }];
    [self.tLab2 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.tLab1.mas_bottom).offset(10);
        make.left.offset(20);
    }];
    [self.tLab3 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.tLab2.mas_bottom).offset(10);
        make.left.offset(20);
    }];
    [self.kfBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.offset(kNavBarHeight+9);
        make.right.offset(-21);
        make.width.offset(99);
        make.height.offset(33);
    }];
    
    self.bgView = [[UIView alloc]init];
    self.bgView.backgroundColor = [UIColor whiteColor];
    self.bgView.bounds = CGRectMake(0, 0, kScreenW, kScreenH-168-kNavBarHeight);
    [self.bgView dc_cornerRadius:26 rectCorner:UIRectCornerTopLeft|UIRectCornerTopRight];
    [self.view addSubview:self.bgView];
    
    self.tLab4 = [[UILabel alloc]init];
    self.tLab4.text = @"登录后继续操作";
    self.tLab4.textColor = [UIColor colorWithHexString:@"#333333"];
    self.tLab4.font = PFRFontMedium(24);
    [self.bgView addSubview:self.tLab4];
    
    self.phoneImageV = [[UIImageView alloc]init];
    self.phoneImageV.image = [UIImage imageNamed:@"sji"];
    [self.bgView addSubview:self.phoneImageV];
    
    self.phoneTF = [[UITextField alloc]init];
    self.phoneTF.textColor = [UIColor colorWithHexString:@"#333333"];
    self.phoneTF.font = [UIFont systemFontOfSize:14];
    self.phoneTF.placeholder = @"请输入手机号";
    [self.bgView addSubview:self.phoneTF];
    
    self.phoneLineLab = [[UILabel alloc]init];
    self.phoneLineLab.backgroundColor = [UIColor colorWithHexString:@"#EEEEEE"];
    [self.bgView addSubview:self.phoneLineLab];
    
    self.pwdImageV = [[UIImageView alloc]init];
    self.pwdImageV.image = [UIImage imageNamed:@"mima"];
    [self.bgView addSubview:self.pwdImageV];
    
    self.pwdTF = [[UITextField alloc]init];
    self.pwdTF.textColor = [UIColor colorWithHexString:@"#333333"];
    self.pwdTF.font = [UIFont systemFontOfSize:14];
    self.pwdTF.placeholder = @"请输入密码";
    [self.bgView addSubview:self.pwdTF];
    
    self.changeBtn = [[ExpandButton alloc]init];
    [self.changeBtn setImage:[UIImage imageNamed:@"biy"] forState:UIControlStateNormal];
    [self.changeBtn setImage:[UIImage imageNamed:@"yan"] forState:UIControlStateSelected];
    self.changeBtn.selected = NO;
    [self.changeBtn addTarget:self action:@selector(changeClick) forControlEvents:UIControlEventTouchUpInside];
    [self.bgView addSubview:self.changeBtn];
    
    self.pwdLineLab = [[UILabel alloc]init];
    self.pwdLineLab.backgroundColor = [UIColor colorWithHexString:@"#EEEEEE"];
    [self.bgView addSubview:self.pwdLineLab];
    
    self.loginBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    self.loginBtn.backgroundColor = [UIColor colorWithHexString:@"#106CFA"];
    [self.loginBtn setTitle:@"登录" forState:UIControlStateNormal];
    [self.loginBtn setTitleColor:[UIColor colorWithHexString:@"#ffffff"] forState:UIControlStateNormal];
    [self.loginBtn addTarget:self action:@selector(loginClick) forControlEvents:UIControlEventTouchUpInside];
    [self.bgView addSubview:self.loginBtn];
    
    self.choseBtn = [[ExpandButton alloc]init];
    [self.choseBtn setImage:[UIImage imageNamed:@"wxuanz"] forState:UIControlStateNormal];
    [self.choseBtn setImage:[UIImage imageNamed:@"xuanz"] forState:UIControlStateSelected];
    [self.choseBtn addTarget:self action:@selector(choseBtnClick) forControlEvents:UIControlEventTouchUpInside];
    [self.bgView addSubview:self.choseBtn];
    
    self.choseLab = [[YYLabel alloc]init];
    self.choseLab.textColor = [UIColor colorWithHexString:@"#AFAFB8"];
    self.choseLab.font = [UIFont systemFontOfSize:12];
    self.choseLab.numberOfLines = 0;
    [self.view addSubview:self.choseLab];
    
    [self.bgView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.tLab3.mas_bottom).offset(23);
        make.left.right.bottom.offset(0);
    }];
    [self.tLab4 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.bgView.mas_top).offset(47);
        make.centerX.equalTo(self.bgView.mas_centerX).offset(0);
    }];
    [self.phoneImageV mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.bgView.mas_left).offset(40);
        make.top.equalTo(self.tLab4.mas_bottom).offset(47);
        make.width.height.offset(20);
    }];
    [self.phoneTF mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self.phoneImageV.mas_centerY).offset(0);
        make.left.equalTo(self.phoneImageV.mas_right).offset(15);
        make.right.equalTo(self.bgView.mas_right).offset(-39);
        make.height.offset(20);
    }];
    [self.phoneLineLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.phoneImageV.mas_bottom).offset(9);
        make.right.equalTo(self.bgView.mas_right).offset(-39);
        make.left.equalTo(self.bgView.mas_left).offset(40);
        make.height.offset(0.5);
    }];
    [self.pwdImageV mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.bgView.mas_left).offset(40);
        make.top.equalTo(self.phoneLineLab.mas_bottom).offset(45);
        make.width.height.offset(20);
    }];
    [self.changeBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self.pwdImageV.mas_centerY).offset(0);
        make.right.equalTo(self.bgView.mas_right).offset(-39);
        make.height.offset(20);
        make.width.offset(44);
    }];
    [self.pwdTF mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self.pwdImageV.mas_centerY).offset(0);
        make.left.equalTo(self.pwdImageV.mas_right).offset(15);
        make.right.equalTo(self.changeBtn.mas_left).offset(-5);
        make.height.offset(20);
    }];
    [self.pwdLineLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.pwdImageV.mas_bottom).offset(9);
        make.right.equalTo(self.bgView.mas_right).offset(-39);
        make.left.equalTo(self.bgView.mas_left).offset(40);
        make.height.offset(0.5);
    }];
    
    [self.loginBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.pwdLineLab.mas_bottom).offset(55);
        make.left.equalTo(self.bgView.mas_left).offset(40);
        make.right.equalTo(self.bgView.mas_right).offset(-40);
        make.height.offset(45);
    }];
    [self.choseBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        if (@available(iOS 11.0, *)) {
            make.bottom.equalTo(self.bgView.mas_bottom).offset(-36-kTabFootBar);
        } else {
            // Fallback on earlier versions
            make.bottom.equalTo(self.bgView.mas_bottom).offset(-36);
        }
        make.left.equalTo(self.bgView.mas_left).offset(69);
        make.width.height.offset(12);
    }];
    [self.choseLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self.choseBtn.mas_centerY).offset(0);
        make.right.equalTo(self.bgView.mas_right).offset(-40);
        make.left.equalTo(self.choseBtn.mas_right).offset(6);
        make.height.offset(40);
    }];
    
    WEAKSELF;
    NSString *str = @"登录即同意《用户协议》和《隐私政策》";
    NSMutableAttributedString *titleText = [[NSMutableAttributedString alloc] initWithString:str];
    NSRange range1 = [str rangeOfString:@"《隐私协议》"];
    NSRange range2 = [str rangeOfString:@"《用户协议》"];
    [titleText setTextHighlightRange:range1 color:[UIColor colorWithHexString:@"#46A0FF"] backgroundColor:nil tapAction:^(UIView * _Nonnull containerView, NSAttributedString * _Nonnull text, NSRange range, CGRect rect) {
        
    }];
    [titleText setTextHighlightRange:range2 color:[UIColor colorWithHexString:@"#46A0FF"] backgroundColor:nil tapAction:^(UIView * _Nonnull containerView, NSAttributedString * _Nonnull text, NSRange range, CGRect rect) {
       
    }];
    YYTextContainer *container = [YYTextContainer containerWithSize:CGSizeMake(kScreenW, MAXFLOAT)];;
    YYTextLayout *titleTextLayout = [YYTextLayout layoutWithContainer:container text:titleText];
    self.choseLab.textLayout = titleTextLayout;
}
#pragma mark---联系客服-----
- (void)kfClick{
    
}
#pragma mark----眼睛点击-----
- (void)changeClick {
    self.changeBtn.selected = !self.changeBtn.selected;
}
#pragma mark ----登录-----
- (void)loginClick{
    YNSHomeController *homeVC = [[YNSHomeController alloc]init];
    self.view.window.rootViewController = [[UINavigationController alloc]initWithRootViewController:homeVC];
}
#pragma mark-----勾选规则-----
- (void)choseBtnClick {
    
}
@end
